
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qf.model.Person;
import com.qf.utils.JedisPoolUtil;
import org.junit.Test;
import redis.clients.jedis.Jedis;

public class Demo1 {
    @Test
    public void jsonTest() throws Exception {
        Person person =new Person();
        person.setId(11);
        person.setName("张三");
        person.setAge(20);
        person.setAddress("杭州九堡");
        person.setSex("男");

        ObjectMapper objectMapper = new ObjectMapper();
        String json = objectMapper.writeValueAsString(person);

        Jedis jedis = JedisPoolUtil.getJedis();
        jedis.select(1);
        String set = jedis.set("person:" + person.getId(), json);
        System.out.println(set);
        String personString = jedis.get("person:" + person.getId());
        System.out.println("personString = " + personString);
        JedisPoolUtil.close(jedis);

    }


    @Test
    public void byteTest() throws Exception {
        Person person =new Person();
        person.setId(22);
        person.setName("张三");
        person.setAge(20);
        person.setAddress("杭州九堡");
        person.setSex("男");
        Jedis jedis = JedisPoolUtil.getJedis();
    }
}
